package org.rsbot.loader.script.adapter;

import org.rsbot.loader.asm.ClassAdapter;
import org.rsbot.loader.asm.ClassVisitor;
import org.rsbot.loader.asm.MethodAdapter;
import org.rsbot.loader.asm.MethodVisitor;

public class SetSuperAdapter extends ClassAdapter
{
  private String superName;
  private String newSuperName;

  public SetSuperAdapter(ClassVisitor paramClassVisitor, String paramString)
  {
    super(paramClassVisitor);
    this.newSuperName = paramString;
  }

  public void visit(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, String[] paramArrayOfString)
  {
    this.superName = paramString3;
    this.cv.visit(paramInt1, paramInt2, paramString1, paramString2, this.newSuperName, paramArrayOfString);
  }

  public MethodVisitor visitMethod(int paramInt, String paramString1, String paramString2, String paramString3, String[] paramArrayOfString)
  {
    if (paramString1.equals("<init>"))
      return new MethodAdapter(this.cv.visitMethod(paramInt, paramString1, paramString2, paramString3, paramArrayOfString)) {
        public void visitMethodInsn(int paramInt, String paramString1, String paramString2, String paramString3) {
          if ((paramInt == 183) && (paramString1.equals(SetSuperAdapter.this.superName))) {
            paramString1 = SetSuperAdapter.this.newSuperName;
          }
          this.mv.visitMethodInsn(paramInt, paramString1, paramString2, paramString3);
        }
      };
    return this.cv.visitMethod(paramInt, paramString1, paramString2, paramString3, paramArrayOfString);
  }
}